import { makeAutoObservable } from "mobx";

class homeData {
  constructor() {
    makeAutoObservable(this);
  }

  //banner列表
  bannerList = [];
  setBannerList = val => {
    this.bannerList = val;
  };

  //热销列表
  hotSellList = [];
  setHotSellList = val => {
    this.hotSellList = val;
  };

  //一级分类
  goodsClass = [];
  setGoodsClass = val => {
    this.goodsClass = val;
  };

  //综合列表
  compList = [];
  setCompList = val => {
    val.forEach(item => {
      this.goodsClass.forEach(subItem => {
        if (item.goods_classify_id === subItem.id) {
          item.goods_classify_id = subItem.name;
        }
      });
    });
    this.compList = val;
  };

  //价格高排序
  priceHight = [];
  setPriceHight = val => {
    val.forEach(item => {
      this.goodsClass.forEach(subItem => {
        if (item.goods_classify_id === subItem.id) {
          item.goods_classify_id = subItem.name;
        }
      });
    });
    this.priceHight = val;
  };

  //销量高排序
  sellHight = [];
  setSellHight = val => {
    val.forEach(item => {
      this.goodsClass.forEach(subItem => {
        if (item.goods_classify_id === subItem.id) {
          item.goods_classify_id = subItem.name;
        }
      });
    });
    this.sellHight = val;
  };
}

const homeStore = new homeData();
export default homeStore;
